﻿<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>条码档案信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />

    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script src="~/js/layui/layui.js"></script>

    <script type="text/html" id="barDemo">
        <a title="条码补打" href="javascript:;" lay-event="print" id="frmReprint"><i class="layui-icon">&#xe66d;</i></a>
        <a title="条码作废" href="javascript:;" lay-event="del" id="frmDrop"><i class="layui-icon">&#xe640;</i></a>

    </script>

</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm" onsubmit="return false;">


                            <div class="layui-inline layui-show-xs-block" style="margin-left:2%">
                                <input type="text" name="barCode" placeholder="查询条码" class="layui-input" id="barCode" style="width:120%">
                            </div>


                        </form>
                    </div>
              
                </div>
            </div>
            <div style="float:left;background-color:white;width:25%;margin-left:1%">
                <div id="treeNav" class="demo-tree demo-tree-box" style="width: 100%; height:550px;overflow: scroll;float:left;"></div>

            </div>

            <div class="layui-card-body"  style="width:69%;margin-left:3px;float:left;background-color:#fff">
                <form id="dForm" class="layui-form layui-col-space5" lay-filter="form-filter">
                <div class="layui-form-item" style="margin-top:3%;margin-left:2%">

                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                           条码编码
                        </div>
                            <input type="text" id="barCode" name="barCode" class="layui-input" style="width:120%" readonly />
                    </div>

                    <div class="layui-input-group" style="float:left;margin-left:100px">
                        <div class="layui-input-prefix">
                            生产工序
                        </div>
                            <input type="text" id="gxName" name="gxName" class="layui-input" style="width:120%" readonly />
                 
                    </div>
                </div>
                    <div class="layui-form-item" style="margin-top:2%;margin-left:2%">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                        存货编码
                        </div>
                            <input type="text" id="proCode" name="proCode" class="layui-input" style="width:120%" readonly />
                    </div>

                    <div class="layui-input-group" style="float:left;margin-left:100px">
                        <div class="layui-input-prefix">
                         存货名称
                        </div>
                            <input type="text" id="proName" name="proName" class="layui-input" style="width:120%" readonly />
                    </div>
                </div>
                    <div class="layui-form-item" style="margin-top:2%;margin-left:2%">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                           条码米数
                        </div>
                            <input type="text" id="proMeter" name="proMeter" class="layui-input" style="width:120%" readonly />
                    </div>

                        <div class="layui-input-group" style="float:left;margin-left:100px" >
                        <div class="layui-input-prefix">
                            条码重量
                        </div>
                            <input type="text" id="proWeight" name="proWeight" class="layui-input" style="width:120%" readonly />
                    </div>
                </div>
                    <div class="layui-form-item" style="margin-top:2%;margin-left:2%">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                            生产时间
                        </div>
                            <input type="text" id="createtime" name="createtime" class="layui-input" style="width:120%" readonly />
                    </div>

                    <div class="layui-input-group" style="float:left;margin-left:100px">
                        <div class="layui-input-prefix">
                          关联计划
                        </div>
                            <input type="text" id="planCode" name="planCode" class="layui-input" readonly />
                    </div>
                </div>
                    <div class="layui-form-item" style="margin-top:2%;margin-left:2%">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                           生产人员
                        </div>
                            <input type="text" id="pusersName" name="pusersName" class="layui-input" style="width:280%" readonly />
                    </div>

                </div>
                <div class="layui-form-item" style="margin-top:2%;margin-left:2%">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                           使用重量
                        </div>
                            <input type="text" id="useWeight" name="useWeight" class="layui-input" readonly />
                    </div>

                    <div class="layui-input-group" style="float:left;margin-left:100px">
                        <div class="layui-input-prefix">
                            使用米数
                        </div>
                            <input type="text" id="useMeter" name="useMeter" class="layui-input" readonly />
                    </div>
                </div>
                    <div class="layui-input-group" style="margin-top:2%;margin-left:2%">
                        <div class="layui-input-prefix">
                            关联条码
                        </div>
                        <input type="text" id="relationBar" name="relationBar" class="layui-input" style="width:350%" readonly />
                    </div>
                </form>
            </div>
        </div>
       
          
        </div>
  
</body>

</html>

<script>
    var barCodes = "";


    function queryData() {
        loadBarTree();
    }

 

    var webCode = "";
    $(function () {
        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");
    
    })

    function loadBarTree() {
        $.ajax({
            url: "../Summary/BarTree",
            data: { datas: JSON.stringify(FormToJson("qForm")) },
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.result) {
                    BarTree(data.data);
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }

    function BarTree(data) {
        var tree = layui.tree;
        var layer = layui.layer;
        var util = layui.util;
        //开启节点操作图标
        tree.render({
            elem: '#treeNav'
            , data: data
            , click: function (obj) {
                var info = getBracketContent(obj.data["title"]);
                showBarInfo(obj.data["id"]);
                if (info != "") { 
                    var arr = info.split("/");
                    $("input[ name='useMeter']").val(arr[0]);
                    $("input[ name='useWeight']").val(arr[1]);
                }
            }
        });
    }
    /**
     * 获取小括号值
     * **/
    function getBracketContent(str) {
        let regex = /\((.*?)\)/;
        let match = regex.exec(str);
        return match ? match[1] : "";
    }

    function showBarInfo(barCode) {
       
        $.ajax({
            url: "../Bar/GetBarCodeInfoByCode",
            data: { barCode: barCode },
            dataType: "json",
            type: "POST",
            success: function (rsl) {
              
                if (rsl.result) {
                    layui.use('form', function () {
                        var form = layui.form;
                        form.val('form-filter',rsl.data[0] );
                        form.render();
                    });
                } 
            }
        });
    }




</script>
